home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGSCAL
/
PULL32TP.LZH
/
PULLDOWN.DOC
< prev
next >
Wrap
Text File
|
1988-10-21
|
27KB
|
1,255 lines
Pulldown Menu User's Guide
Version 3.0 of 'Pulldown Menus'
October 21, 1988
PREFACE:
This is the full documentation for the enhanced versions of
the Pulldown Menus (ver 2 & 3). The stripped down pulldown
menu TPU file is a subset of the enhanced versions. Four
stars (****) will be placed next to the Function or
Procedure name of any routine that is only available in the
enhanced versions of the Pulldown Menus.
INTRODUCTION
The set of files contained in this archive consist of a
pulldown menu system with pop up menu windows, integrated
Microsoft Mouse support, and routines to save and restore
the current window and the cursor. This code was written
with the Turbo Pascal compiler (Version 5). Compatability
with previous versions of Turbo Pascal is not possible since
the pulldown menu system is written as a Turbo Pascal Unit.
The problem with most pulldown menu libraries is that it is
usually a pain in the neck to figure out how make it work
properly. This pulldown menu system was designed with the
idea that you should only have to provide basic information
about what you want the headers to say, what you want
displayed in each submenu, where you want the headers
located on the pulldown menu bar, etc. And, you should only
have to load this information into arrays as strings or
characters.
This system is generic in the sense that you can specify up
to 10 headers (pulldown menu titles), and up to 10 submenus
under each header. You load the pulldown menu headers,
submenu entries, and popup menu contents into pre-defined
arrays, and the pulldown menu system will do the rest by
generating the pulldown menus. The Pulldown Menu system is
treated like a call to a Library routine.
One (obvious) caution is that you must ensure that the
headers and submenus will fit on a single line. Therefore,
it is best to keep the header and submenu entries as concise
as possible.
Page 1
Pulldown Menu User's Guide
HOW TO USE THE PULLDOWN & POPUP MENU SYSTEM
To use the pulldown menu system, specify the following:
1) The number of headers in the pulldown menu.
2) The column each header should start in.
3) The number of entries in each pulldown menu's submenu.
4) The width of each pulldown menu submenu.
5) The title (if any) that will appear on the first line
(within the frame).
6) The justification for the title (left, right or center).
7) The popup menu X and Y starting location
8) The popup menu width
9) The number of entries in the popup menu.
PULLDOWN MENU RETURN VARIABLES
The pulldown menu system returns three variables:
1) Pulldown_Menu_Number - Identifies which pulldown menu
header was selected.
2) Pulldown_Menu_Selection - Identifies which submenu entry
was selected.
3) PopUp_Menu_Selection - Identifies which pop up menu
entry was selected.
These variables are global to your program. By setting up a
Case statement, you can identify which menus were selected
and call your corresponding routines.
PULLDOWN MENU SELECTIONS
Selections can be made by moving the cursor to the desired
item and hitting the return key. A short cut method is to
hit the key corresponding to the number or capitalized first
letter displayed in a highlighted color. Once the main
pulldown menu displays a submenu, you can hit the left or
right arrow keys to go from one pulldown menu header to the
next, or use the up or down arrow keys to move within the
submenu. If you want to back out of the submenu, hit the
ESC key. With the enhanced version, you can also use a
Page 2
Pulldown Menu User's Guide
mouse. To select an item, position the mouse cursor over
the desired item and click either the left or right button.
Any combination of keyboard or mouse selections is allowable
in the enhanced version.
PULLDEMO.PAS - DEMO FILE
PullDemo.PAS is a template file to help you get your code
integrated into the pulldown menu system as fast as
possible. This file should be examined to see how you
should load the data structures, set up your case
statements, etc. I have provided sample headers and
submenus to show the types of program control that may be
set up.
Pulldown Menu #1, Sub Menu Item #2 should be examined
closely. A demonstration is provided to show how you can
get a selection from the popup menu, do something, and then
return to the popup menu instead of the main pulldown menu
system.
PULLDOWN MENU INITILAIZATION
This template file also shows you how to initialize the main
pulldown menu, submenu and popup menu systems. You are
currently limited to 10 headers, 10 submenu entries, and 20
PopUp Menu entries. However, these values can be changed at
will to suit your particular application by changing a
constant (marked in the source file).
The major revision as of version 2.0 of this program was the
use of dynamic variables for the submenu and popup menu data
structures. The submenu pointer approach reduces the data
stack from 57K bytes to less than 6K bytes.
The popup menu pointers reduces this further to 2797 bytes.
Because pointers are involved, you must use the NEW ()
statement when initializing the submenus and popup menus.
An example is as follows:
New (SubMenu[1]);
With Submenu[1]^ do
begin
........
end;
You don't have to initialize the unused portions of the data
structures. That is, if you have 7 pulldown menu headers
you don't have to initialize or use submenus 8, 9, & 10.
Page 3
Pulldown Menu User's Guide
NOTE: *************************
If you don't want a submenu under a main menu header, you
must still initialize the submenu and enter 0 for the number
of submenu entries.
*************************
Make sure that you set DirectVideo to TRUE in your program
so that the screen writes occur as fast as possible.
Before you call Make_Menu, you must initialize the array
containing the menu entries, that is passed to the
procedure. The initialization is simple and consists of
using the New statement to create the pointer variable and
loading the menu entries in the array. I suggest that you
keep the initialization as a callable procdure as shown in
the template file, rather than performing the initialization
in the body of your code.
Note that when using the enhanced version, the
initialization must also include the MOUSE_INIT procedure.
MOUSE_INIT is called AFTER the DrawMainHeader procedure.
Example,
MainMenu_Init;
Submenu_Init
DrawMainHeader;
Mouse_Init;
The complete initialization is shown in the template file.
Page 4
Pulldown Menu User's Guide
GLOBAL PROCEDURES AND FUNCTIONS
Page 5
Pulldown Menu User's Guide
CURSOR_OFF
Declaration: cursor_off;
Remarks: This procedure turns the text cursor
off.
Restrictions: Must be in text mode.
Example:
.
.
.
write ("Here''s the cursor ... ");
delay (2000); {2 second delay}
cursor_off;
writeln;
write ("Now it''s gone ....... ");
delay (1000);
writeln;
write ("Now it's back again .. ");
cursor_on;
.
.
.
See: CURSOR_ON
Page 6
Pulldown Menu User's Guide
CURSOR_ON
Declaration: cursor_on;
Remarks: This procedure turns the text cursor on
after a call to CURSOR_OFF has been
made.
Restrictions: Must be in text mode.
Example:
.
.
.
write ("Here''s the cursor ... ");
delay (2000); {2 second delay}
cursor_off;
writeln;
write ("Now it''s gone ....... ");
delay (1000);
writeln;
write ("Now it's back again .. ");
cursor_on;
.
.
.
See: CURSOR_OFF
Page 7
Pulldown Menu User's Guide
**** DIRECTRY
Declaration: directry;
Remarks: This procedure prompts the user for a
file mask. A window is created
displaying all of the files found that
fit the specified mask. This procedure
uses the MakeWindow procedure. The
underlying screen is automatically saved
and restored upon entry and exit of the
procedure.
Restrictions: Must be in text mode.
Example:
.
.
.
Directry; {everything is handled in this
higher level procedure}
.
.
.
Page 8
Pulldown Menu User's Guide
DRAWMAINHEADER
Declaration: DrawMainHeader;
Remarks: This procedure displays the main
pulldown menu header. This is called as
an initialization in the main body of
your program.
Restrictions: Must be in text mode.
Example:
.
.
.
DrawMainHeader;
.
.
.
Page 9
Pulldown Menu User's Guide
**** GOTOXY_MOUSE
Declaration: GotoXY_Mouse (var Col, Row : Integer);
Remarks: This procedure is similar to the GotoXY
routine built into Turbo Pascal. If the
mouse driver is installed in memory,
this procedure will position the mouse
cursor to the specified column and row.
Restrictions: Must be in text mode and MOUSE.COM
driver must be loaded in memory.
Example:
.
.
.
GotoXY_Mouse (10,15); {positions the mouse
cursor in column 10, row
15}
.
.
.
See: MOUSE_INSTALLED, HIDE_MOUSE, SHOW_MOUSE
Page 10
Pulldown Menu User's Guide
**** HIDE_MOUSE
Declaration: Hide_Mouse;
Remarks: This procedure turns the mouse cursor
off. This is used with the Boolean
function Mouse_Installed. If
Mouse_Installed is True then you can
hide the mouse cursor.
Restrictions: MOUSE.COM must be loaded in memory.
Example:
.
.
.
If Mouse_Installed then
begin
Hide_Mouse;
{do other things}
Show_Mouse;
end;
.
.
.
See: MOUSE_INSTALLED, SHOW_MOUSE, GOTOXY_MOUSE
Page 11
Pulldown Menu User's Guide
MAKEMENU
Declaration: MakeMenu (var start_row, start_col,
menu_width, number_of_menu_entries,
foreground_color, background_color,
frame_color : Integer; Menu_Contents :
MenuPtr);
Remarks: This procedure displays a pop up menu.
The items that are displayed as
selections are contained in the array of
pointers of type MenuPtr (See template
file). The screen contents are NOT
automatically saved and restored upon
entry and exit to the procedure. You
must execute the SAVESCREEN &
RESTORESCREEN procedures yourself.
Restrictions: Must be in text mode.
Example:
.
.
.
MakeMenu (33, 12, 13, 5, blue, lightgray, blue,
Menu_Items[5]);
.
.
.
See: SAVESCREEN, RESTORESCREEN
Page 12
Pulldown Menu User's Guide
**** MAKEWINDOW
Declaration: MakeWindow (var start_row, start_col,
window_width, number_of_rows_in_window,
foreground_color, background_color,
frame_color, title_color : Integer;
Justification : Char; Title : string80;
Shadow : Boolean);
Remarks: This procedure displays a pop up window.
A title can be specified as a string. If
no title is desired, specify "". The
title can be right, left or center
justified in the screen. If Shadow is
True, a shadow is drawn "under" the
window to provide a 3-D effect. The
screen contents are automatically saved
and restored upon entry and exit to the
procedure.
Restrictions: Must be in text mode.
Example:
.
.
.
Cursor_off;
makewindow (10, 10, 20, 5, white, red, black,
yellow, 'c', "Hello, World", True);
GotoXy (1,1);
writeln ("Here''s some text in the window ...");
repeat until keypressed;
restorewindow;
cursor_on;
.
.
.
See: RESTOREWINDOW
Page 13
Pulldown Menu User's Guide
**** MOUSE
Declaration: Mouse (var M1, M2, M3, M4, M5 :
Integer);
Remarks: This procedure is the main mouse command
interface routine. Integers are loaded
into the variables M1 through M5, then
Mouse (..) is called. Refer to the
Microsoft Mouse Programmer's reference
Guide for details on all of the mouse
functions.
Restrictions: MOUSE.COM must be loaded in memory.
Example:
.
.
.
M1 := 3; {Get mouse position and button status}
M2 := 0; M3 := 0; M4 := 0; M5 := 0;
Mouse (M1, M2, M3, M4, M5);
{returns button status in M2, horizontal cursor
position in M3, and vertical cursor position in
M4}
.
.
.
See: MOUSE_INSTALLED, GOTOXY_MOUSE, HIDE_MOUSE, SHOW_MOUSE
Page 14
Pulldown Menu User's Guide
**** MOUSE_INIT
Declaration: Mouse_Init;
Remarks: This is the initialization procedure for
the mouse routines. If MOUSE.COM is
installed the mouse cursor is enabled
and centered on the screen. This
procedure is called as part of the
Pulldown Menu initialization process in
the main body of the program. See the
program template for an example.
Restrictions: Must be in text mode and MOUSE.COM must
be installed in memory.
Example:
.
.
.
Mouse_Init;
{checks to see if MOUSE.COM is installed, if true
then show the mouse cursor and center it on the
screen.}
.
.
.
See: MOUSE_INSTALLED, GOTOXY_MOUSE, HIDE_MOUSE, SHOW_MOUSE
Page 15
Pulldown Menu User's Guide
**** MOUSE_INSTALLED
Declaration: Mouse_Installed;
Remarks: This function checks to see if the
MOUSE.COM driver is installed. It
returns a Boolean value.
Restrictions: None.
Example:
.
.
.
If Mouse_Installed then
begin
{do something}
end;
.
.
.
See: GOTOXY_MOUSE, HIDE_MOUSE, SHOW_MOUSE
Page 16
Pulldown Menu User's Guide
RESTORE_SCREEN
Declaration: Restore_Screen;
Remarks: This procedure restores the last saved
screen. The counter that keeps track of
the number of saved screens is
automatically decremented by 1. Note
that the higher level routines
MakeWindow and RestoreWindow
automatically save and restore
underlying screens. MakeMenu does not.
Note that in the stripped version of the
pulldown menu system, only 1 screen can
be saved or restored.
Restrictions: None.
Example:
.
.
.
save_screen;
{do something}
restore_screen;
.
.
.
See: MAKEWINDOW, RESTOREWINDOW, MAKEMENU, SAVE_SCREEN
Page 17
Pulldown Menu User's Guide
SAVE_SCREEN
Declaration: Save_Screen;
Remarks: This procedure saves a screen to an
array in memory. The counter that keeps
track of the number of saved screens is
automatically incremented by 1. Note
that the higher level routines
MakeWindow & RestoreWindow automatically
save and restore underlying screens.
MakeMenu does not. Note that in the
stripped version of the pulldown menu
system, only 1 screen can be saved or
restored.
Restrictions: None.
Example:
.
.
.
save_screen;
{do something}
restore_screen;
.
.
.
See: MAKEWINDOW, RESTOREWINDOW, MAKEMENU, RESTORE_SCREEN
Page 18
Pulldown Menu User's Guide
**** SHOW_MOUSE
Declaration: Show_Mouse;
Remarks: This procedure shows the mouse cursor
that has previously been turned off with
a call to Hide_Mouse.
Restrictions: MOUSE.COM must be installed.
Example:
.
.
.
If Mouse_Installed then
begin
Hide_Mouse;
{do something}
Show_Mouse;
end;
.
.
.
See: MOUSE_INSTALLED, HIDE_MOUSE
Page 19